<?php
$sites = array(
	'rapidshare.com' => 'type="submit" value="Free user"',
	'megaupload.com' => '<a href="javascript:checkcaptcha();"><IMG SRC="http://wwwstatic.megaupload',
	'megashares.com' => '<div class="order_push">',
	'easy-share.com' => 'You are requesting',
	'mediafire.com' => 'Share this file:',
	'hotfile.com' => 'onclick="starttimer();',
	'rapidshare.de' => 'You want to download',
	'depositfiles.com' => 'File name: <b title=',
	'yourfilehost.com' => 'Description:',
	'sendspace.com' => 'Download Link: <span id="spn_download_link">',
	'netload.in' => 'more than <span class="dl_first_orange">2</span> minutes</div>',
	'filecactory.com' => '<label>Text link</label>',
	'4shared.com' => 'HTML code:',
	'zshare.net' => '<input name="imageField" type="image" id="imageField" src="/images/download.gif" width="219" height="',
	'ziddu.com' => '">File Size :',
	
);

function cleanurl ($url,$path=false) {
	$url = parse_url($url);
	
	if (array_key_exists('host', $url)) {
		$url['host'] = str_replace('www.', '', $url['host']);
		if (preg_match('@(\w+)\.(\w+)\.(\w+)@im',$url['host'],$matches)) {
			$url['host'] = $matches[2].'.'.$matches[3];
		}
		$url = ($path!=false) ? $url['host'].((array_key_exists('path', $url) != false) ? $url['path'] : '/') : $url['host'];
		return($url);
	}
	return(false);
}

function curl_page($url) {
	$c = curl_init();
	curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($c, CURLOPT_URL, $url);
	curl_setopt($c, CURLOPT_TIMEOUT, 10);
	curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 10);
	curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($c, CURLOPT_MAXREDIRS, 2);
	curl_setopt($c, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 5.1; U; en) Presto/2.2.15 Version/10.01');
	curl_setopt($c, CURLOPT_REFERER, $url);
	$contents = curl_exec($c);
	curl_close($c);
	if (!empty($contents)) {
	return $contents;
	}
	else
	{
	return FALSE;
	}

}



if (isset($_REQUEST['array_links']) && !empty($_REQUEST['array_links'][0])) {

$alive = array();
$dead = array();
foreach ($_REQUEST['array_links'] as $link) {
	$conts = null;
	$templink = null;
	$goodstr = null;
	$badlink = TRUE;
	$templink = urldecode(strtolower(cleanurl($link,false)));
	if (array_key_exists($templink,$sites) == TRUE) {
		$conts = curl_page($link);
		if (stristr($conts, $sites[$templink]) != FALSE) {
			$badlink = FALSE;
			echo "alive\r\n$link";
		}
		else
		{
			echo "dead\r\n$link";
		}
	}
}
}
?>